package A;

public class Test_14 {
    public static void main(String[] args) {
        String s = "this is a test of java";
        //(1) 创建方法int getCharNum(char c),统计该字符串中字母s出现的次数
        //(2) 通过截取 取出子字符串"test"
        //(3) 将'java'替换为'JAVASE'
        s = s.substring(0, s.indexOf("test")) + s.substring(s.indexOf("test") + 5);
        s = s.replace("java", "JAVASE");
        System.out.println(s);
    }

    public static int getCharNum(String s) {
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if ("s".equals(s.charAt(i)+"")) {
                count++;
            }
        }
        return count;
    }
}
